//
//  SwiftUIView.swift
//  波形图demo
//
//  Created by apple on 2021/3/25.
//

import SwiftUI

struct SwiftUIView: View {
    @State private var username: String = ""
    @State private var isEditing = false

    var body: some View {
        TextField(
            "User name (email address)",
             text: $username
        ) { isEditing in
            self.isEditing = isEditing
        } onCommit: {
            print(username)
        }
//        .autocapitalization(.none)
        .disableAutocorrection(true)
        .border(Color.green)
        .frame(width: 300, height: 50, alignment: .center)
        Text(username)
            .foregroundColor(isEditing ? .red : .blue)
        TextField(
            "User name (email address)",
             text: $username
        ) { isEditing in
            self.isEditing = isEditing
        } onCommit: {
            print(username)
        }
//        .autocapitalization(.none)
        .disableAutocorrection(true)
        .border(Color.green)
        .frame(width: 300, height: 50, alignment: .center)
    }
//    var body: some View {
//        Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
//            .onTapGesture {
//                let group = DispatchGroup()
//                for index in 0...120 {
//                    DispatchQueue.global().async(group: group, execute: DispatchWorkItem.init(block: {
//                        Thread.sleep(forTimeInterval: TimeInterval(arc4random_uniform(2) + 1))
//                         print("任务\(index)执行完毕")
//                    }))
//                }
//
//                group.notify(queue: DispatchQueue.main, work: DispatchWorkItem.init(block: {
//                    print("任务\(String(describing: index))执行完毕")
//                }))
//            }
//    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        SwiftUIView()
    }
}
